package com.wyth.lottery.utils;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;

import com.wyth.lottery.R;


/**
 * Created by Administrator on 2017/9/6.
 */

public class Bitmap {

    public static android.graphics.Bitmap bitmaptest( Context context ) {

        Bitmap mBitmap;
        Rect mSrcRect, mDestRect;
        String itemName ="你好打印机";

        int w = 600;
        int h = 600;

        //Bitmap qr = BarcodeUtils.creatBarcode(BaseApplication.getContext(), "16887498665498", w / 3, h / 4, true);
        android.graphics.Bitmap mbmpTest = android.graphics.Bitmap.createBitmap(w, h, android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(mbmpTest);
        canvas.drawColor(Color.WHITE);

        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setAntiAlias(true);
        //左对齐
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setTextSize(100);
        paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));//粗体


        //canvas.drawText(itemName, 250,350, paint);//品名

        paint.setStyle(Paint.Style.FILL);//充满
        paint.setColor(Color.LTGRAY);
        paint.setAntiAlias(true);// 设置画笔的锯齿效果
        //canvas.drawText("画圆角矩形",250,500, paint);




        //图片的宽和高
       Resources resources = context.getResources();
        android.graphics.Bitmap bmp = BitmapFactory.decodeResource(resources, R.drawable.zj);
        mSrcRect = new Rect(0,0,600,600);
        mDestRect = new Rect(30,0,800,800);
        canvas.drawBitmap(bmp,mSrcRect,mDestRect,paint);
      /*  RectF oval3 = new RectF(80, 400, 300, 400);// 设置个新的长方形
        canvas.drawRoundRect(oval3, 20, 15, paint);//第二个参数是x半径，第三个参数是y半径*/

        return mbmpTest;
    }
}
